//
//   Copyright 2011 Gynvael Coldwind & Mateusz "j00ru" Jurczyk
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//
#pragma once
#include <stdint.h>
using namespace std;

#define DOOR_OPEN      0
#define BUTTON_PRESSED 0

enum TILE_TYPE
{
  TILE_WALL = 0,
  TILE_FLOOR,
  TILE_DOOR_V, // Door (vert) : [var_ID]
  TILE_DOOR_H, // Door (horiz): [var_ID]
  TILE_START_POINT,
  TILE_END_POINT,
  TILE_EXIT,
  TILE_HOLE,
  TILE_NOTHING,
  TILE_STD_BUTTON,
  TILE_TOGGLE_BUTTON, // Params: [var ID] [initial_state = 0 or 1]
  TILE_TELEPORT       // Params: [var ID] [dst teleport var ID]
};

typedef struct tagTILE_STRUCT
{
  enum TILE_TYPE tileType;
  int32_t params[4]; // XXX: 4 parameters should definitely be enough
} TILE_STRUCT;

typedef struct tagMAP_STRUCT
{
  int width;
  int height;
  TILE_STRUCT** tiles;
} MAP_STRUCT;

typedef struct tagLEVEL_STRUCT
{
  int mapCount;
  int activeMap;
  float deadline;
  MAP_STRUCT** maps;
  
  int playerCount;
} LEVEL_STRUCT;

// Public functions
LEVEL_STRUCT* game_LoadLevel();

MAP_STRUCT* readMapFromFile(char* filename, int id, int* maps, int* players, float* deadline);
LEVEL_STRUCT* readLevelFromFile(char* filename);


